package com.easyedu.core.dao;

import com.easyedu.core.entity.dto.ClassRoomBuildingInfo;
import com.easyedu.core.entity.po.Classroom;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @author lmr
 **/
@Mapper
public interface ClassRoomDao {

     /**
      * 功能描述: 获取教室信息
      *
      * @return : java.util.List<com.easyedu.api.entity.DO.Classroom>
      **/
     @Select("select * from classroom")
     List<Classroom> getClassroom();

     /**
      * 功能描述:插入教室
      *
      * @param classrooms 1 教室集 classroom表 Persistant Object
      * @return : java.lang.Integer
      **/
     Integer createClassroom(List<Classroom> classrooms);

     /**
      * 功能描述:更新教室信息
      *
      * @param classroom 1 教室 classroom表 Persistant Object
      * @return : java.lang.Integer
      **/
     @Update("update classroom set classroom_name = #{classroomName} ,belong_build = #{belongBuild},seats = #{seats},"
             + "classroom_type = #{classroomType} where " + "classroom_id = #{classroomId}")
     Integer updateClassroom(Classroom classroom);

     /**
      * 功能描述: 删除教室
      *
      * @param classroomId 1 教室id
      * @return : java.lang.Integer
      **/
     @Delete("delete from classroom where classroom_id = #{classroomId}")
     Integer deleteClassroom(Long classroomId);

     /**
      * 功能描述: 根据教室名称查询教室信息
      *
      * @param classroomName 1 教室名称
      * @return : java.util.List<com.easyedu.api.entity.DO.Classroom>
      **/
     @Select("select * from classroom where classroom_name = #{classroomName}")
     Classroom getClassroomByName(String classroomName);

     /**
      * 功能描述: 插入一个教室
      *
      * @param classroom 1 教室 classroom表 Persistant Object
      * @return : java.lang.Integer
      **/
     @Insert("insert into classroom(classroom_name, belong_build, seats, classroom_type) VALUES (#{classroom"
             + ".classroomName},#{classroom.belongBuild},#{classroom.seats},#{classroom.classroomType})")
     Integer createOneClassroom(Classroom classroom);

     /**
      * 功能描述: 根据教室id查询教室
      *
      * @param classroomId 1 教室id
      * @return : com.easyedu.api.entity.DO.Classroom
      **/
     @Select("select * from classroom where classroom_id = #{classroomId}")
     Classroom getClassroomById(long classroomId);

     /**
      * 根据座位数排序的教室
      * @param buildName
      * @param floor
      * @return
      */
     @Select("select * from classroom where belong_build = #{buildName} and floor = #{floor} order by seats ASC;")
     List<Classroom> getClassroomBySeat(String buildName, int floor);

     /**
      * 获取教室及教学楼信息
      * @param classroom 教室名
      * @return 教室及教学楼信息
      */
     @Select("select b.*,c.* from  building_address b, classroom c where b.build_name = c.belong_build and "
             + "classroom_name = #{classroom}")
     ClassRoomBuildingInfo getClassroomInfoByName(String classroom);

     /**
      * 获取教室数量
      * @return 教室数量
      */
     @Select("select count(*) from classroom ")
     int getClassRoomCount();
}
